package com.zmzncs.lmtc.module.park.controller;


import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.pojo.bolian.QuoteField;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.park.pojo.bolian_pull.BolianPull;
import com.zmzncs.lmtc.module.park.pojo.bolian_pull.UpdateNewField;
import com.zmzncs.lmtc.module.park.pojo.park_info.ParkInfoDTO;
import com.zmzncs.lmtc.module.park.pojo.park_info.ParkInfoVO;
import com.zmzncs.lmtc.module.park.service.BolianPullService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 停车场-泊链-拉取 前端控制器
 * </p>
 *
 * @author 高博文
 * @since 2021-03-15
 */
@Api(tags = "泊链停车场")
@RestController
@RequestMapping("/park/bolian-pull")
@Validated
public class BolianPullController {

    @Autowired
    BolianPullService bolianPullService;

    @ApiOperation(value = "获取未处理泊链停车场信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @GetMapping(value = "/getPendingBolianPark")
    public Rest<List<BolianPull>> getPendingBolianPark(){
        List<BolianPull> bolianPullList = bolianPullService.getPendingBolianPark();
        return RestUtil.success(bolianPullList);
    }

    @ApiOperation(value = "引入泊链车场更新字段")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType="query", name = "updateField", value = "变动字段", required = true),
    })
    @PostMapping(value = "/quoteFieldFromBolian")
    public Rest<List<QuoteField>> quoteFieldFromBolian(@NotNull String updateField){
        List<QuoteField> bolianPullList = bolianPullService.quoteFieldFromBolian(updateField);
        return RestUtil.success(bolianPullList);
    }

    @ApiOperation(value = "忽略/引入泊链停车场新数据")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
    })
    @PostMapping(value = "/updateNewDataField")
    public Rest updateNewDataField(@RequestBody UpdateNewField updateNewField){
        bolianPullService.updateNewDataField(updateNewField);
        return RestUtil.success();
    }

}

